package o.json;

import java.util.Collection;

public class JSONFactory2 extends JSONFactory {

	@Override
	public JSONValue create(Object object) {
		if (object == null) return new JSONNull();

		final JSONObject o = new JSONObject();
		o.setValue(new JSONString(object.getClass().getName()), super.create(object));
		return o;
	}

	@Override
	public JSONValue create(Object[] array) {
		if (array == null) return new JSONNull();

		final JSONArray a = new JSONArray();
		for (Object o : array) {
			a.addValue(create(o));
		}
		return a;
	}

	@Override
	public JSONValue create(Collection<?> array) {
		if (array == null) return new JSONNull();

		final JSONArray a = new JSONArray();
		for (Object o : array) {
			a.addValue(create(o));
		}
		return a;
	}
}
